package com.augurit.common.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.augurit.common.base.dao.BaseDao;
import com.augurit.common.calendar.web.form.SysCalSharedForm;
import com.augurit.common.entity.SysCalShared;

@Repository
public class SysCalSharedDao extends BaseDao<SysCalShared, Long> {
	public List<Long> getEditors(Long eventId){
		return this.getByShareType(eventId, SysCalSharedForm.WRITE_SHARE_TYPE);
	}
	
	public List<Long> getReaders(Long eventId){
		return this.getByShareType(eventId, SysCalSharedForm.READ_SHARE_TYPE);
	}
	
	public List<Long> getByShareType(Long eventId, String shareType){
		if(eventId != null){
			String hql = "select share.shareUserId from SysCalShared share where share.eventId = ? and share.shareType = ?";
			return this.find(hql, eventId, shareType);
		}
		return null;
		
	}
}